package com.sdutcm.Util;

/*
 *@Author Yan
 *@Create 2019-08-20 23:04
 */

import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.stereotype.Component;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.format.DateTimeFormatter;
import java.util.Date;
@Component
public class TimeUtils {
    private static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

    public static String formatDate(Date date) {
        synchronized(sdf){
            return sdf.format(date);
        }
    }
    public static Date parse(String strDate) {
        synchronized (sdf) {
            try {
                return sdf.parse(strDate);
            } catch (ParseException e) {
                e.printStackTrace();
            }
            return null;
        }
    }
}
